package uk.co.nazz.f21mc_a2.diary;

import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Locale;

public class Event {
	private Calendar start;
	private String title;
	private long id;
	private Boolean isRecurring = false;
	private int attendeeCount;

	/**
	 * This class represents an event to be displayed in a list view
	 * 
	 * @param start
	 *            - Start date and time
	 * @param title
	 *            - Title of event
	 * @param id
	 *            - _ID of event
	 * @param isRecurring
	 *            - boolean - true if event recurring
	 * @param attendeeCount
	 *            - number of attendees
	 */
	public Event(Calendar start, String title, long id, Boolean isRecurring,
			int attendeeCount) {
		this.start = start;
		this.title = title;
		this.id = id;
		this.isRecurring = isRecurring;
		this.attendeeCount = attendeeCount;

	}

	/**
	 * @return _Id of event
	 */
	public long getId() {
		return id;
	}

	/**
	 * 
	 * @return - number of attendees for an event
	 */
	public int getAttendeeCount() {
		return attendeeCount;
	}

	/**
	 * 
	 * @return - true if event is recurring 
	 */
	public Boolean getIsRecurring() {
		return isRecurring;
	}

	/**
	 * return truncated string containing date/time and title of event 
	 */
	public String toString() {
		// limit the width of the 'toString' text
		String titleString = "";
		if (title.length() > 28) {
			titleString = title.substring(0, 25) + "...";
		} else {
			titleString = title;
		}
		SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy HH:mm", Locale.UK);
		return titleString + " " + sdf.format(start.getTime());

	}
}